<template>
    <div>
      <p>请签字</p>
      <div id="signature">
        <div class="btn">
          <span style="background: #ffc655" @click="cancel">取消</span>
          <span style="background: #10AEFF" @click="reset">重置</span>
          <span @click="save">保存</span>
        </div>
      </div>
    </div>
</template>

<script>
  export default {
    name: "",
    data(){
      return {
        uid:'',
        width:'',
        height:''
      }
    },
    mounted(){
      this.uid = this.$route.query.uid;
      // 获取手机屏幕的宽高
      this.width = window.screen.availWidth
      this.height = window.screen.availHeight
      // 初始化画布
      $("#signature").jSignature({height:this.height,width:this.width,color:"#000",lineWidth:4,'background-color':'none'});
    },
    methods:{
      msg(str){
        this.$vux.toast.show({
          type: 'text',
          text: str,
          position: 'default',
          time: 800,
        });
      },
      // 重置
      reset(){
        $("#signature").jSignature("clear");
      },
      // 保存
      save(){
        var sig=$("#signature");
        // var str = window.btoa(unescape(encodeURIComponent(sig.jSignature('getData'))))
        this.$vux.loading.show();
        this.config0.post3('/supply/appOrder/orderSign', {
          orderId:this.uid,
          base64Str:sig.jSignature('getData')
        }).then(res=>{
          this.$vux.loading.hide();
          if(res.data.code==='0'){
            this.$router.push({ path: '/project0/view1/order' })
            this.msg(res.data.message);
          }else{
            this.msg(this.config0.handleError(res.data));
          }
        })
      },
      cancel(){
        this.$router.push({ path: '/project0/view1/order' })
      }
    },

  }
</script>

<style scoped lang="less">
#signature{
  /*position: absolute;*/
  .btn{
    position: absolute;
    left:0;
    bottom:0;
    span{
      display: block;
      margin-bottom: 1.5rem;
      margin-top: 3rem;
      background: #33bb99;
      padding: 0 1rem;
      line-height:2.5rem;
      border-radius: 5px;
      color: #fff;
      transform:rotate(90deg);
      -ms-transform:rotate(90deg); 	/* IE 9 */
      -moz-transform:rotate(90deg); 	/* Firefox */
      -webkit-transform:rotate(90deg); /* Safari 和 Chrome */
      -o-transform:rotate(90deg);	/* Opera */
    }
  }

}
p{
  display: inline-block;
  position: absolute;
  bottom:0;
  top:0;
  left:-40%;
  z-index: -1;
  font-size: 2.5rem;
  font-weight: 600;
  letter-spacing: 10px;
  color: #f1f1f1;
  transform:rotate(90deg);
  -ms-transform:rotate(90deg); 	/* IE 9 */
  -moz-transform:rotate(90deg); 	/* Firefox */
  -webkit-transform:rotate(90deg); /* Safari 和 Chrome */
  -o-transform:rotate(90deg);	/* Opera */
}
</style>
